package com.ityunhe.dao.impl;

import java.util.List;

import javax.management.RuntimeErrorException;

import org.apache.ibatis.session.SqlSession;

import com.ityunhe.bean.Collectgarden;
import com.ityunhe.bean.Collectgoods;
import com.ityunhe.dao.CollectManageDao;
import com.ityunhe.factory.MybatisUtil;

public class CollectManageDaoImpl implements CollectManageDao {

	@Override
	public int saveCollectgarden(Collectgarden collectgarden) {
		int result=0;
		SqlSession session = MybatisUtil.getSession();
		CollectManageDao mapper = session.getMapper(CollectManageDao.class);
		
		try {
			result = mapper.saveCollectgarden(collectgarden);
			session.commit();
		} catch (Exception e) {
			throw new RuntimeException("添加收藏信息异常");
		}finally{
			MybatisUtil.closeSession();
		}
		
		return result;
	}

	@Override
	public int saveCollectgoods(Collectgoods collectgoods) {
		int result=0;
		SqlSession session = MybatisUtil.getSession();
		CollectManageDao mapper = session.getMapper(CollectManageDao.class);
		
		try {
			result = mapper.saveCollectgoods(collectgoods);
			session.commit();
		} catch (Exception e) {
			throw new RuntimeException("添加收藏信息异常");
		}finally{
			MybatisUtil.closeSession();
		}
		
		return result;
	}

	@Override
	public int removeCollectgarden(Collectgarden collectgarden) {
		int result=0;
		SqlSession session = MybatisUtil.getSession();
		CollectManageDao mapper = session.getMapper(CollectManageDao.class);
		try {
			result = mapper.removeCollectgarden(collectgarden);
			session.commit();
		} catch (Exception e) {
			throw new RuntimeException("删除收藏信息异常");
		}finally{
			MybatisUtil.closeSession();
		}
		
		return result;
	}

	@Override
	public List<Collectgarden> getCollectgardenList(Collectgarden collectgarden) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int removeCollectgoods(Collectgoods collectgoods) {
		int result=0;
		SqlSession session = MybatisUtil.getSession();
		CollectManageDao mapper = session.getMapper(CollectManageDao.class);
		try {
			result = mapper.removeCollectgoods(collectgoods);
			session.commit();
		} catch (Exception e) {
			throw new RuntimeException("删除收藏信息异常");
		}finally{
			MybatisUtil.closeSession();
		}
		
		return result;
	}

	@Override
	public List<Collectgoods> getCollectgoodsList(Collectgoods collectgoods) {
		// TODO Auto-generated method stub
		return null;
	}

}
